package cn.itsource.ymcc.feign.fallback;

import cn.itsource.ymcc.domain.Login;
import cn.itsource.ymcc.feign.LoginFeign;
import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginFeignFallbackFactory implements FallbackFactory<LoginFeign> {
    @Override
    public LoginFeign create(Throwable throwable) {
        return new LoginFeign() {
            @Override
            public JsonResult saveOrUpdate(Login login) {
                log.error(throwable.getMessage());
                return JsonResult.error(throwable.getMessage());
            }
        };
    }
}
